<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuimini/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" readonly  value="<<<.user_info.AdminUser>>>" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" name="pass_word"  placeholder="请输入密码" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="role_id" lay-filter="role_id">
                <option value="0">请选择</option>
                <<<range $index, $elem := .role_list>>>
                    <<<if eq $index $.user_info.RoleId >>>
                    <option selected value="<<<$index>>>"><<<$elem>>></option>
                    <<<else>>>
                    <option  value="<<<$index>>>"><<<$elem>>></option>
                    <<<end>>>
                <<<end>>>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="gender" value="1" title="男" <<<if eq .user_info.Gender 1 >>>checked=""<<<end>>>>
            <input type="radio" name="gender" value="2" title="女" <<<if eq .user_info.Gender 2 >>>checked=""<<<end>>>>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">手机</label>
        <div class="layui-input-block">
            <input type="number" name="phone" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机" value="<<<.user_info.Mobile>>>" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="email" name="email" placeholder="请输入邮箱" value="<<<.user_info.Email>>>" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"><<<.user_info.Remark>>></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            <input type="hidden" name="id" value="<<<.user_info.Id>>>">
        </div>
    </div>
</div>
</div>
<script src="/static/layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            data = data.field
            $.ajax({
                url: "/admin/ajax_admin_user_edit",
                data:{id:data.id,pass_word:data.pass_word,role_id:data.role_id,gender:data.gender,phone:data.phone,email:data.email,remark:data.remark},
                type:"POST",
                success: function(data){
                    layer.msg(data.msg);
                    if(data.code == 10000){
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);

                        parent.layui.table.reload('currentTableId',{page:{curr:1}}); //demo表格id
                    }
                }
            });

            return false;
        });

    });
</script>
</body>
</html>